import Vue from 'vue'
import App from './App.vue'
import router from './router'
import vuex from 'vuex'
import store from './store/index.js';
import Global from './tools/global';
import common from './tools/common'
import axios from './tools/axiosX';
// import axios from './tools/axiosX';
import echarts from 'echarts'
import 'video.js/dist/video-js.css'
import ElementUI from 'element-ui';
import htmlToPdf from './assets/js/htmlToPdf';
import VueCropper from 'vue-cropper';
import VueAwesomeSwiper from 'vue-awesome-swiper';
import uploader from 'vue-simple-uploader';
import {
  emoji
} from './emoji/emoji.js';
import {
  Message
} from 'element-ui';
import barrage from "vue2-barrage";


import ImageViewer from "./components/common/image-viewer.vue"
import 'element-ui/lib/theme-chalk/index.css';
import 'babel-polyfill';
import "./player/srsRtc.js";
import "./player/DPlayer.min.js";
import 'swiper/dist/css/swiper.css';
import './assets/css/iconfont.css'
import './assets/css/emoji-sprite.scss'
import login from './tools/checkAuth'
require('./../public/css/reset.css');
require('./../public/css/ipng.css');
require('./../public/js/common.js');
// 为了实现Class的私有属性
const showMessage = Symbol('showMessage')
// single默认值true
class DonMessage {
  success(options, single = true) {
    this[showMessage]('success', options, single)
  }
  warning(options, single = true) {
    this[showMessage]('warning', options, single)
  }
  info(options, single = true) {
    this[showMessage]('info', options, single)
  }
  error(options, single = true) {
    this[showMessage]('error', options, single)
  }

  [showMessage](type, options, single) {
    if (single) {
      // 判断是否已存在Message
      if (document.getElementsByClassName('el-message').length === 0) {
        Message[type](options)
      }
    } else {
      Message[type](options)
    }
  }
}

Vue.component('ImageViewer', ImageViewer)

//视频播放
// import videojs from 'video.js'
// import 'video.js/dist/video-js.css'
// import SWF_PATH from 'videojs-swf/dist/video-js.swf';
// videojs.options.flash.swf = SWF_PATH;
// Vue.prototype.$videojs = videojs;
Vue.use(ElementUI);
Vue.use(uploader);
Vue.use(htmlToPdf);
Vue.use(VueCropper);
Vue.use(VueAwesomeSwiper);
Vue.use(barrage);

Vue.prototype.emoji = emoji
Vue.prototype.$message = new DonMessage()
Vue.prototype.$echarts = echarts;
Vue.prototype.$ajax = axios
Vue.prototype.$g = Global; // 全局变量
Vue.prototype.BASE_URL = sessionStorage.getItem('host_addr')

// 提交以后禁用按钮一段时间，防止重复提交
Vue.directive('preventReClick', {
  inserted(el, binding) {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.classList.add('is-disabled')
        el.disabled = true
        setTimeout(() => {
          el.disabled = false
          el.classList.remove('is-disabled')
        }, binding.value || 1000)
      }
    })
  }
});

Vue.config.productionTip = false;
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')